package com.atguigu;

import feign.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;


/**
 * ConsumerApplication
 *
 * @Author: 马伟奇
 * @CreateTime: 2021-03-03
 * @Description:
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker // 打开熔断器
@EnableFeignClients(basePackages = "com.atguigu.feign")
public class ConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class,args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    /**
     * 开启日志
     * Logger.Level.FULL:表示记录所有的请求和响应，非常详细
     * Logger.Level.NONE:不记录日志
     * Logger.Level.BASIC:表示仅仅记录请求方法
     * Logger.Level.HEADERS:在基础的记录上，在加上请求头
     */
    @Bean
    public Logger.Level feignloggerLevel(){
        return Logger.Level.FULL;
    }
}